/*
 * Created on Feb 19, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package org.vectrics.recruiter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Locale;

import org.apache.log4j.Logger;
import org.vectrics.common.db.CodeAndDescription;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.recruiter.job.JobCandidateStatusReasonType;
import org.vectrics.recruiter.job.JobClassification;
import org.vectrics.recruiter.job.JobStatusType;

/**
 * @author MMoore
 */
public class RecruitDisplayUtils {
	private static final Logger log = Logger.getLogger(RecruitDisplayUtils.class);


	/**
	 * Convert a collection JobCandidateStatusReasonType's to a collection of CodeAndDescription objects.  
	 * Find the appropriate names for the locale passed.
	 * @param reasonTypes The collection JobCandidateStatusReasonType's
	 * @param locale The Locale of the user.
	 * @return
	 */
	public static Collection jobCandidateReasonTypesToCoded(Collection reasonTypes, Locale locale) {
		log.debug("jobCandidateReasonTypesToCoded() - called");
		Collection<CodeAndDescription> newList = new ArrayList<CodeAndDescription>();
		Iterator iter = reasonTypes.iterator();
		while (iter.hasNext()) {
			JobCandidateStatusReasonType reasonType = (JobCandidateStatusReasonType)iter.next();
			CodeAndDescription codeObj = new CodeAndDescription();
			codeObj.setCode(reasonType.getCode());
			codeObj.setDescription(CoreServiceLocator.getPhraseProvider()
					.getMessage(reasonType.getName(), locale));
			newList.add(codeObj);
		}
		return(newList);
	}
	
	public static Collection jobStatusTypesToCoded(Collection jobStatusCodedTypes, Locale locale) {
		Collection newList = new ArrayList();
		Iterator iter = jobStatusCodedTypes.iterator();
		while (iter.hasNext()) {
			JobStatusType statusType = (JobStatusType)iter.next();
			CodeAndDescription codeObj = new CodeAndDescription();
			codeObj.setCode(statusType.getCode());
			codeObj.setDescription(statusType.getDescription(locale));
			newList.add(codeObj);
		}
		return(newList);
	}
	
	
	public static Collection jobClassificationsToCoded(Collection allJobClassificationTypes, Locale locale) {	
		Collection newList = new ArrayList();
		Iterator iter = allJobClassificationTypes.iterator();
		while (iter.hasNext()) {
			JobClassification classification = (JobClassification)iter.next();
			CodeAndDescription codeObj = new CodeAndDescription();
			codeObj.setCode(classification.getCode());
			codeObj.setDescription(CoreServiceLocator.getPhraseProvider().getMessage(classification.getDescriptionCode(), locale));
			newList.add(codeObj);
		}
		return(newList);
	}
	
	
}